public class Day_11_1_最近公共祖先 {
    public int getLCA(int a, int b) {
        // write code here
        if(2 * a == b || 2 * a + 1 == b){
            return b;
        }
        if(2 * b == a || 2 * b + 1 == a){
            return a;
        }
        while (a != b) {
            if(a > b){
                a /= 2;
            }else {
                b /= 2;
            }
        }
        return b;
    }
}
